from django.core.mail import send_mail
from rest_framework.response import Response
from rest_framework.views import APIView

from djangoProject1112 import settings


def send_email1(email):
    subject = "测试发布邮件主题"
    message = "测试发布邮件内容"
    from_email = settings.EMAIL_HOST_USER  # 使用 settings 中的默认发件人
    to_email = [email]
    send_status = send_mail(subject, message, from_email, to_email )
    print(f"邮件发送状态：{send_status}")
    return send_status


class HomeView(APIView):
    def get(self, request):
        send_email1('1839880411@qq.com')
        return Response({'message': '邮件发送成功'})
